package com.cy.cloud_project_server.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cy.cloud_project_server.entity.User;
import com.cy.cloud_project_server.service.UserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * TODO(Descriptions)
 * @author changyuan
 * @date 2018年10月23日 上午10:29:23
 * @Copyright: 2018 www.birdsh.com Inc. All rights reserved.
 */
@Controller
@RequestMapping("/user")
@Api(value="user")
public class UserController {
    private static Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    UserService userService;
    
    @GetMapping("/queryAllUserList")
    @ApiOperation("查询所有用户列表")
    @ResponseBody
    public List<User> queryAllUserList(){
        return userService.queryAllUserList();
    }
    
    @GetMapping("/queryUserById")
    @ResponseBody
    @ApiOperation("根据Id查询User")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "用户id", dataType = "Integer", paramType = "query", required = true),
        })
    public User queryUserById(Integer id){
        User user = userService.queryUserById(id);
        logger.info("==> User["+user+"]");
        return user;
    }
}
